package gov.jyy.xzxk.xksq.common.desensitization.impl;

import gov.jyy.xzxk.xksq.common.desensitization.DefaultDesensitization;


/**
 * 中华人民共和国身份证脱敏器
 *
 */
public class IDCardNoDesensitization implements DefaultDesensitization {

    @Override
    public String desensitize(String idCardNumber) {
        String s = idCardNumber.replaceAll("(?<=\\d{6})\\d(?=\\d{4}|$)", "*");
        char c = s.charAt(s.length() - 1);
        if(c == 'X') {
            return s.replace("X", "*");
        }
        if(c == 'x') {
            return s.replace("x", "*");
        }
        return s;
    }

}